import java.util.Comparator;

public class SequentialSearch<T> {

    private Comparator<T> comparator;

    public SequentialSearch(Comparator<T> comparator) {
        this.comparator = comparator;
    }

    public int search(T[] array, T key) {
        for (int i = 0; i < array.length; i++) {
            T element = array[i];
            if (comparator.compare(key, element) == 0) {
                return i;
            }
        }

        return -1;
    }
}
